package com.marvels.financial.loan.dao;

import com.github.pagehelper.Page;
import com.marvels.financial.funds.dto.ConfirmTransferCalculateDTO;
import com.marvels.financial.loan.dto.LoanAuditConditionDto;
import com.marvels.financial.loan.dto.McfeLendingProcess;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

public interface McfeLendingProcessDao {
    int deleteByPrimaryKey(Long id);

    int insert(McfeLendingProcess record);

    int insertSelective(McfeLendingProcess record);

    McfeLendingProcess selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(McfeLendingProcess record);

    int updateByPrimaryKey(McfeLendingProcess record);
    
    /**
     * 更新调整金额
     * @param record
     * @return
     */
    int updateLoanAmountAdjust(McfeLendingProcess record);
    
    
    /**
     * 根据loanId和状态查询申请信息
     * @param loanId
     * @param status
     * @return
     */
    public McfeLendingProcess selectByloanIdAndStatus(@Param("loanId") String loanId,@Param("status") String status);
    
    /**
     * 更新审核结果
     * @param record
     * @return
     */
   public int updateAuditResult(McfeLendingProcess record);
   
   
   /**
    * 查询处于放款信息列表
    * @param listQueryConditionDto
    * @return
    */
   public  Page<McfeLendingProcess> selectLendProcessList(LoanAuditConditionDto loanAuditConditionDto);
   
   /**
    * 查询放款统计信息
    * @param listQueryConditionDto
    * @return
    */
   public McfeLendingProcess selectLendProcessAmountStatic(LoanAuditConditionDto loanAuditConditionDto);
   
   
   /**
    * 更新loanId对应的批次号 和is_busy
    * @param batName
    * @return
    */
   public int updateBatNameByLoanId(@Param("batName") String batName,@Param("threadId") String threadId,@Param("orginStatus") String orginStatus,@Param("loanId") String loanId);
   
   
   /**
    * 更新批次号 和is_busy
    * @param batName 
    * @param threadId
    * @param orginStatus  原始状态
    * @param lendType  放款类型   1 人工  2自动
    * @return
    */
   public int updateAuditBatName(@Param("batName") String batName,@Param("threadId") String threadId,@Param("orginStatus") String orginStatus,@Param("lendType") String lendType);
   
   
   /**
    * 更新批次号 和is_busy
    * @param batName 
    * @param threadId
    * @param orginStatus  原始状态
    * @param lendType  放款类型   1 人工  2自动
    * @param orderNumber
    * @return
    */
   public int updateAuditInfo(@Param("batName") String batName,@Param("threadId") String threadId,@Param("orginStatus") String orginStatus,@Param("lendType") String lendType,@Param("orderNumber") String orderNumber);
   
   
   /**
    * 根据批次号
    * @param status
    * @return
    */
   public List<McfeLendingProcess> selectByBatName(@Param("batName") String batName,@Param("threadId") String threadId,@Param(value="status") String status);
   
   
  /**
   * 统计当天成功的金额
   * @param fundCode
   * @return
   */
   public BigDecimal selectTodayAmount(@Param("fundCode") String fundCode);
   
   
   
   /**
    * 根据时间段查询放款金额
    * @param beginTime
    * @param endTime
    * @return
    */
   public ConfirmTransferCalculateDTO selectLendAmountTimeSlot(@Param("beginTime") Date beginTime,@Param("endTime") Date endTime);
   
   
   
   /**
    * 查询需要同步还款计划的放款成功的放款记录
    * @return
    */
   public List<McfeLendingProcess> selectNeedSynchroPlan(@Param("fundCodeList") List<String> fundCodeList);
   
   
   /**
    * 通过身份证查询放款信息
    * @param custCardNo
    * @return
    */
   public McfeLendingProcess selectByCustIdNumber(@Param("custCardNo") String custCardNo);
}